#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.59])
AC_INIT(sniffsniff, 1.0, damien.finck@etu.unistra.fr)
AM_INIT_AUTOMAKE

# Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
AC_CHECK_PROG([HAVE_GNUPLOT], [gnuplot], [true], [false])
if test "x$HAVE_GNUPLOT" = "xfalse"; then
    AC_MSG_ERROR("Error: Required program gnuplot not found. Install it and try again.")
fi

# Checks for libraries.
AC_CHECK_LIB([pcap], [pcap_loop], [LIBS="-lpcap $LIBS"], echo "Error: Required library libpcap not found. Install it and try again." && exit 1)
AC_CHECK_LIB([ncurses], [initscr], [LIBS="-lncurses $LIBS"], echo "Error: Required library libncurses not found. Install it and try again." && exit 1)
AC_CHECK_LIB([cdk], [drawLine], [LIBS="-lcdk $LIBS"], echo "Error: Required library libcdk not found. Install it and try again." && exit 1, [-lncurses])

# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL

# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_CHECK_FUNCS([alarm memset mkdir])


if test "x$GCC" = "xyes"; then
  CFLAGS="$CFLAGS -Wall -g"
fi
AC_CONFIG_FILES([Makefile
                 src/Makefile])
AC_OUTPUT
